<style scoped lang="scss">
.div1 {
  .userimg {
    width: 30px;
    height: 30px;
    margin: 10px;
  }

  display: flex;
  justify-content: space-between;
  background: #fff;

  .search1 {
    flex: 1;
  }

  .icon1 {
    font-size: 30px;
    margin: 10px;
  }
}
</style>
<template>
    <van-sticky>
        <div class="div1">
            <!-- <img img" @click="onicon1" /> -->
            <!-- <img v-if="userimg" src="../../assets/images/image/xhdpi/girl.png" alt="" class="userimg" @click="onicon1" /> -->
            <!-- <img v-if="userimg" :src="userImg" alt="" class="userimg" @click="onicon1" /> -->
            <!-- <homeimg  v-if="userimg" class="userimg" @click="onicon1"></homeimg> -->
            <Image v-if="userimg" @click="onicon1" class="userimg" :dataSrc="userImg" ></Image>
            <!-- <img v-if="userimg" :src="userImg" alt="" ref="image" @error="imgs" class="userimg" @click="onicon1" /> -->
            <van-icon v-show="!userId" v-if="showicon1" class="icon1" name="manager" @click="onicon1" />
            <van-icon v-if="showicon2" class="icon1" name="arrow-left" @click="$router.go(-1)" />
            <van-search v-if="showSearch" class="search1" shape="round" background="#fff" placeholder="请输入搜索关键词"
                @click="onsearch" />
            <van-nav-bar v-if="showbar" class="search1" :title="name" />
            <van-nav-bar v-if="showbar2" class="search1" title="设置" />
            <van-nav-bar v-if="showbar3" class="search1" title="版本检测" />
            <van-nav-bar v-if="showbar4" class="search1" title="邀请好友" />
            <van-nav-bar v-if="showbar5" class="search1" title="视频" />
            <van-nav-bar v-if="showbar6" class="search1" title="历史评价" />
            <van-nav-bar v-if="showbar7" class="search1" title="我的关注" />
            <van-nav-bar v-if="showbar8" class="search1" :title="doctorName" />
            <el-icon v-if="showicon3" class="icon1" @click="onicon2">
                <Bell />
            </el-icon>
        </div>
    </van-sticky>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import homeimg from '../homeimg/index.vue'
import Image from '../image/index.vue'
const nickName=JSON.parse(localStorage.getItem('result') as string).nickName
const userImg = JSON.parse(localStorage.getItem("result") as string).headPic
const name = JSON.parse(localStorage.getItem('hname') as string)
console.log(name)
const userId = ref(localStorage.getItem('userId'))
console.log(userId.value, 'userId')

const route = useRoute()
const doctorName:any = ref(route.query.doctorName)
console.log(doctorName.value)

const answer = ref(false)

if (userId.value) {
  answer.value = true
} else {
  answer.value = true
}

const router = useRouter()
const onicon1 = () => {
  router.push('/my')
}
const onsearch = () => {
  router.push('/homeSearch')
}
const onicon2 = () => {
  router.push('/information')
}
defineProps({
  showSearch: {
    type: Boolean,
    default: false // 默认显示搜索框，可根据实际情况调整
  },
  showbar: {
    type: Boolean,
    default: false
  },
  showbar2: {
    type: Boolean,
    default: false
  },
  showbar3: {
    type: Boolean,
    default: false
  },
  showicon1: {
    type: Boolean,
    default: true
  },
  showicon2: {
    type: Boolean,
    default: false
  },
  showicon3: {
    type: Boolean,
    default: true
  },
  showbar4: {
    type: Boolean,
    default: false
  },
  showbar5: {
    type: Boolean,
    default: false
  },
  showbar6: {
    type: Boolean,
    default: false
  },
  showbar7: {
    type: Boolean,
    default: false
  },
  showbar8: {
    type: Boolean,
    default: false
  },
  userimg: {
    type: Boolean,
    default: false
  }
})
</script>
